Repository navigation
Conversation
The Table starters wrap the column name in a Group with role="presentation"
and tabIndex={-1} so it can take focus apart from the ColumnResizer. A
focusable presentational element is announced with no role, so a screen
reader user has no cue that activating it changes the sort order.
Render a plain div instead, with role="button" when the column allows
sorting and no role otherwise. Group only supplied the focus ring state, so
the focus ring now uses :focus-visible.
Closes adobe#8502
snowystinger
left a comment
Member
There was a problem hiding this comment.
the change to the css file may be causing the CI failure
yarn check:starter-css
Hook starter CSS is out of date:
Table.css
Run: yarn sync:starter-css
| border-radius: var(--radius-sm); | ||
|
|
||
| &[data-focus-visible] { | ||
| &:focus-visible { |
| {({allowsSorting, sortDirection}) => ( | ||
| <div className="column-header"> | ||
| <Group role="presentation" tabIndex={-1} className="column-name"> | ||
| <div role={allowsSorting ? 'button' : undefined} tabIndex={-1} className="column-name"> |
Member
There was a problem hiding this comment.
Was there a reason you didn't do this?
Suggested change
| <div role={allowsSorting ? 'button' : undefined} tabIndex={-1} className="column-name"> | |
| <div role={allowsSorting ? 'button' :'presentation'} tabIndex={-1} className="column-name"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8502
Summary
The Table starters wrap the column name in a
Groupwithrole="presentation"andtabIndex={-1}, so it can take focus separately from theColumnResizer. A focusable element with a presentational role is announced with no role at all, so a screen reader user who lands on the name gets no cue that activating it changes the sort order.Following the review on #10364, this drops
Grouprather than widening itsroletype. The name is now a plaindiv:role="button"when the column allows sorting, and no role when it does not, since a non sortable name does nothing when activated.tabIndex={-1}is unchanged in both cases, so focus still moves between the name and the resizer as before. Clicks and Enter still reach the column header's own press handling, so sorting works the same way.Groupwas only supplying the focus ring state, so the focus ring moves to:focus-visible:&:focus-visiblein the vanilla starter'sTable.css, andfocus-visible:classes in the Tailwind starter, matching the coloursfocusRingused and the same patternToast.tsxalready uses there.Changed:
starters/docs/src/Table.tsx,starters/docs/src/Table.css,starters/tailwind/src/Table.tsx. Both are rendered by the React Aria Table docs. No package code changes.AI use: AI tooling assisted with this change. I reviewed every line and can explain each decision.
📝 Test Instructions
yarn check-types: passes.yarn oxfmt --checkon the three changed files: passes.oxlintdoes not coverstarters/.buttonand accessible name "Name", the plain one has no role, and clicking or pressing Enter on the button callsonSortChangeonce. Onmainthe same test fails: no element with rolebuttonis found.To check manually: open the React Aria Table docs, sorting example. Arrow into a sortable header and onto its name: it is announced as a button, the focus ring shows, and Enter sorts. A non sortable column's name is not announced as a button.
Recording of the docs starter Table in Chromium, same keys on both sides: ArrowUp onto Name, Enter twice, ArrowRight onto Type, Enter. The box in the corner shows the focused element's role and name from Chrome's accessibility tree.
Before (
main): the sortable name isgeneric.After: the sortable name is
button, Type staysgeneric, the focus ring looks the same, and Enter still sorts.Side by side: before-after.mp4
Not yet checked: forced colors, RTL, Firefox, Safari, and the Tailwind starter in a browser.
Release impact
✅ PR Checklist
🧢 Your Project
Nclusion